package com.twu.biblioteca.representation;

import com.twu.biblioteca.representation.command.Command;
import com.twu.biblioteca.representation.factory.CommandFactory;

import java.util.Scanner;

public class CommandExecutor {

    private static final String BYE = "bye";
    Scanner sc;

    public CommandExecutor() {
        sc = new Scanner(System.in);
    }
        public Command parseOption(String optionStr) {
        Command command = null;
            if (optionStr.equals("1")) {
            command= CommandFactory.createCommand("BookView");
        }
        else if(optionStr.equals("2")) {
            command=CommandFactory.createCommand("BookReserve");
        }
        else if(optionStr.equals("3")) {
            command=CommandFactory.createCommand("MovieView");
        }
        else if(optionStr.equals("4")) {
            command=CommandFactory.createCommand("Login");
        }
        else if(optionStr.equals("5")) {
            command=CommandFactory.createCommand("UserView");
        }
        else if(optionStr.equals("q")) {
            System.out.println(BYE);
            System.exit(0);
        }
        return command;
    }

    public String  executeCommand(Command command) {
        String resultStr=command.execute();
        return resultStr;
    }
}
